package cn.kbyue.ormdemo.service.impl;

import cn.kbyue.ormdemo.entity.Simple;
import cn.kbyue.ormdemo.mapper.SimpleMapper;
import cn.kbyue.ormdemo.service.ISimpleService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kbyue
 * @since 2023-04-12
 */
@Service
public class SimpleServiceImpl extends ServiceImpl<SimpleMapper, Simple> implements ISimpleService {

    @Override
    public List<Simple> queryList(String name) {
        LambdaQueryChainWrapper<Simple> wrapper = new LambdaQueryChainWrapper<>(Simple.class);
        return wrapper.select(Simple::getId, Simple::getSimpleName, Simple::getDeleted)
                .like(!StringUtils.isEmpty(name), Simple::getSimpleName, name)
                .list();
    }

}
